home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group92c.txt / 000059_icon-group-sender _Thu Nov 5 10:13:58 1992.msg < prev    next >
Internet Message Format  |  1993-01-04  |  3KB

  1. Received: by cheltenham.cs.arizona.edu; Thu, 5 Nov 1992 12:17:22 MST
  2. Date: Thu, 5 Nov 92 10:13:58 EST
  3. From: Paul_Abrahams@MTS.cc.Wayne.edu
  4. To: icon-group@cs.arizona.edu
  5. Message-Id: <523344@MTS.cc.Wayne.edu>
  6. Subject: Semicolons and newlines
  7. Status: R
  8. Errors-To: icon-group-errors@cs.arizona.edu
  9.  
  10. Personally, I very much like the way that Icon handles semicolons and
  11. newlines.  To appreciate it, it helps to look at some history in the
  12. Hegelian terms of thesis, antithesis, and synthesis.  (Idle query: am I
  13. the first person to mention Hegel in this newsgroup?)
  14.  
  15. In the early days of programming languages, Fortran was dominant.  The
  16. Fortran convention is that a newline ends a statement, with an "escape
  17. hatch" in the form of continuation cards.  People generally found the
  18. continuation cards to be an awkward and uncomfortable convention, and
  19. also were looking for a way of placing more than one statement on a line.
  20.  
  21. That thesis--that newlines end statements, but with an escape hatch--led
  22. to the antithesis: that newlines should be ignored altogether and that a
  23. particular character, the semicolon, should be used either to separate
  24. or to terminate statements.  That was the approach of Algol 60, Pascal,
  25. and their numerous successors (which did disagree on the terminator versus
  26. separator question).  That approach is still dominant today.  It is
  27. tolerable, but hardly optimal.
  28.  
  29. Icon, of course, introduced the synthesis: the idea that newlines indeed
  30. ought to be meaningful, but that by themselves they were not sufficient
  31. as a method of ending statements.  (Let's ignore for the purposes of this
  32. discussion the fact that Icon is an expression language.)  I don't know
  33. whether Ralph originated this idea, since it also appears in awk.  It
  34. seems to me that the synthesis has gotten it right: that newlines are too
  35. useful to be ignored and are indeed the natural way of ending a statement,
  36. but that we need some way of overriding the significance of newlines both
  37. to place several statements on a single line and to allow statements to
  38. span lines.
  39.  
  40. One drawback to the Icon approach, but an unavoidable one, is that it
  41. is more natural to begin a continuation line with an operator than to end
  42. the previous line with an operator.  (Or so it seems to me, based perhaps
  43. on my mathematical background; in mathematical writing, continuation
  44. lines of equations usually begin with operators.)  Another drawback in
  45. extending the idea to other languages is that it's necessary for the
  46. lexical scanner to be able to distinguish operators from other lexical
  47. elements.  That may not be easy in a language that allows identifiers to
  48. be defined as operators.  For example, the Icon lexical scanner has to
  49. be able to distinguish between
  50.   x := not
  51.     + z
  52. and
  53.   x := knot
  54.     + z
  55. The second of these gets an inserted semicolon, but the first does not.
  56. If Icon allowed me to define "knot" as an operator, it would be in trouble.
  57.  
  58. Paul Abrahams
  59.  
  60.